﻿@model Model.Object.HinhAnh

@{
    ViewBag.Title = "Create";
    var tensanpham = (string)ViewBag.tensanpham;
    var idsanpham = (int)ViewBag.idsanpham;
}

@using (Html.BeginForm()) {
  <div class="subhead-collapse collapse">
    <div class="subhead">
        <div class="container-fluid">

            <div class="row-fluid">
                <div class="span12">
                    <div class="btn-toolbar" id="toolbar">
                        <div class="btn-wrapper" id="toolbar-apply">
                            <button type="submit" class="btn btn-small btn-success" value="Save" name="Submit">
                                <span class="icon-apply icon-white"></span>
                                Save
                            </button>
                        </div>
                        <div class="btn-wrapper" id="toolbar-save">
                            <button type="submit" class="btn btn-small" value="SaveClose" name="Submit">
                                <span class="icon-save"></span>
                                Save &amp; Close
                            </button>
                        </div>
                        <div class="btn-wrapper" id="toolbar-save-new">
                            <button type ="submit" class="btn btn-small" value="SaveNew" name="Submit" class="btn btn-small">
                                <span class="icon-save-new"></span>
                                Save &amp; New
                                </button>
                        </div>
                        <div class="btn-wrapper" id="toolbar-cancel">
                            <a href="@Url.Action("Index", new {idsanpham=idsanpham})" class="btn btn-small">
                                <span class="icon-cancel"></span>
                                Cancel
                            </a>

                        </div>
                        <div class="btn-group divider"></div>
                        <div class="btn-wrapper" id="toolbar-help">
                            <button rel="help" class="btn btn-small">
                                <span class="icon-question-sign"></span>
                                Help
                            </button>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
    <div class="container-fluid container-main">
        <section id="content">
            <!-- Begin Content -->
            <h2> Bạn đang thêm hình cho sàn phẩm "@tensanpham"</h2>
            <div class="row-fluid">
                <div id="system-message-container">
                </div>
                <div class="row-fluid">

                    @Html.ValidationSummary()
                    <fieldset>

					    @Html.AntiForgeryToken()

        <div class="control-group">
		<div class="control-label">
            @Html.LabelFor(model => model.Ten)
        </div>
        <div class="controls">
            @Html.EditorFor(model => model.Ten)
            @Html.ValidationMessageFor(model => model.Ten)
        </div>
		</div>

        <div class="control-group">
		<div class="control-label">
            @Html.LabelFor(model => model.ImagePath)
        </div>
        <div class="controls">
            @Html.HiddenFor(model => model.ImagePath)
            <input type="button" id="chonhinhbtn" value="Chon hinh" />
            <img id="img-hinhanh" style="width:50px;height:50px"/>
            @Html.ValidationMessageFor(model => model.ImagePath)
        </div>
		</div>

        <div class="control-group">
		<div class="control-label">
            @Html.LabelFor(model => model.ID_SanPham, "SanPham")
        </div>
        <div class="controls">
            @Html.Hidden("ID_SanPham",idsanpham)
          @*  @Html.DropDownList("ID_SanPham", String.Empty)

            @Html.ValidationMessageFor(model => model.ID_SanPham)*@
        </div>
		</div>

        <div class="control-group">
		<div class="control-label">
            @Html.LabelFor(model => model.ID_LoaiHinhAnh, "LoaiHinhAnh")
        </div>
        <div class="controls">
            @Html.DropDownList("ID_LoaiHinhAnh", String.Empty)
            @Html.ValidationMessageFor(model => model.ID_LoaiHinhAnh)
        </div>
		</div>

         </fieldset>	
    </div>

 </div>
            <!-- End Content -->
        </section>

    </div>
}


@section Scripts {
@Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryval")
	@System.Web.Optimization.Scripts.Render("~/ckeditor/ckeditor.js")
@System.Web.Optimization.Scripts.Render("~/ckeditor/config.js")
@System.Web.Optimization.Scripts.Render("~/ckfinder/ckfinder.js")

}
<script type="text/javascript">
    $(document).ready(function () {
        $("#chonhinhbtn").click(function () {
            var finder = new CKFinder();
            finder.selectActionFunction = function (fileUrl) {
                $('#ImagePath').val(fileUrl);
                
                $('#img-hinhanh').attr("src", fileUrl)
            };
            finder.popup();
        });
    });
</script>